import Vue from 'vue';
import Router from 'vue-router';
import Home from '@/components/home';
import Write from '@/components/write/write';

Vue.use(Router)

let router = new Router({
	mode: 'history',
  routes: [
    {
      path: '/',
      name: 'home',
      component: Home
    },
//  {
//    path: '/write',
//    name: 'write',
//    component: Write
//  },
    {
      path: '/text',
      name: 'text',
      component: () =>
			import('@/components/text.vue')
    },
    {
      path: '/info',
      name: 'info',
      component: () =>
			import('@/components/info.vue')
    },
    {
      path: '/god',
      name: 'god',
      component: () =>
			import('@/components/god.vue')
    }
  ]
})
router.beforeEach((to, from, next)=>{
	if(to.name=='text'){
		if(sessionStorage.getItem('user')=='master'){
			next()
		}else{
			next({name:'home'})
		}
	}else{
		next()
	}
//	console.info(to)
//	console.info( from)
//	console.info( next)
	
})
export default router;